package com.lins.framework.utils.tip;

import android.content.DialogInterface;
import android.support.v4.app.FragmentManager;

import com.lins.framework.common.base.MyApplication;

/**
 * Created by Admin on 2017/3/14.
 */

public class DialogUtil {
    /**
     * 接口返回错误信息。只弹出提示框，无任何操作
     *
     * @param msg
     */
    public static void showTipDialog(FragmentManager fm, String msg, String tag) {
        SimpleMDDialog dialog = SimpleMDDialog.newInstance("提示", msg, "确定");
        dialog.setOnOkBtnClickListener(new SimpleMDDialog.OnOkBtnClickListener() {
            @Override
            public void onOkClickListener(DialogInterface dialog) {
                dialog.dismiss();
            }
        });
        dialog.show(fm, tag);
    }

    /**
     * 接口返回成功信息。弹出提示框，确认后关闭当前activity
     *
     * @param msg
     */
    public static void successDialog(FragmentManager fm, String msg, String tag) {
        SimpleMDDialog dialog = SimpleMDDialog.newInstance("提示", msg, "确定");
        dialog.setOnOkBtnClickListener(new SimpleMDDialog.OnOkBtnClickListener() {
            @Override
            public void onOkClickListener(DialogInterface dialog) {
                dialog.dismiss();
                MyApplication.getInstance().getActivityManager().finishThis();
            }
        });
        dialog.show(fm, tag);
    }

}
